package com.huatai.exchange.send;

import com.faneui.common.exception.BusinessException;
import com.huatai.exchange.dal.model.ExcCustDataFile;
import com.huatai.exchange.facade.CommunicationContents;
import com.huatai.exchange.facade.Contents;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("fileMailSendService")
public class FileMailSendServiceImpl extends AbstractFileSendServiceImpl implements FileSendService {

    @Override
    public void sendMessage(  Map<String, Object> resvMap) throws BusinessException {
        boolean b = resvMap.get("fileNames") == null || StringUtils.isBlank(resvMap.get("fileNames").toString());
        String fileNames = b ? null : resvMap.get("fileNames").toString();
        String filePaths = b ? null : resvMap.get("filePaths").toString();

        ExcCustDataFile custDataFile = (ExcCustDataFile) resvMap.get(CommunicationContents.communication_dest);
        String toMails = custDataFile.getDestAddress() ;

        String toCcMails = (String) resvMap.get(CommunicationContents.MAIL_toCcMails);
        String toCcSeMails = (String) resvMap.get(CommunicationContents.MAIL_toSeCcMails);
        String mailTitle = (String) resvMap.get(CommunicationContents.MAIL_TITLE);
        String mailContent = (String) resvMap.get(CommunicationContents.MAIL_CONTENT);
        communicationService.sendMail(mailTitle, mailContent, toMails, fileNames, filePaths,toCcMails,toCcSeMails);
    }
}
